Dynamic hardware detection#71
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the hardware parsing and provisioning capabilities within Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant improvement to hardware parsing by allowing dynamic and generic accelerator requests, which greatly enhances the user experience. The generation-aware fallback and support for canonical aliases are excellent additions. My review focuses on a couple of opportunities to refine the implementation by reducing redundancy and code duplication in the new parsing logic, which will improve long-term maintainability. The accompanying test updates are thorough and provide good coverage for the new features.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces dynamic hardware detection, which is a great enhancement for user experience, aligning well with the API design guidelines of minimizing cognitive load. The changes are extensive, adding support for generic requests like gpu-N and tpu-N, introducing aliases for TPU types, and expanding the hardware registry. The accompanying tests are thorough. I found a logic issue in the implementation of generation-aware prioritization. The search order for accelerators does not correctly prioritize the newest hardware generations as intended. My review includes suggestions to correct this.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable enhancement for dynamic hardware detection, simplifying accelerator requests for users. The changes are well-structured and include comprehensive tests for the new functionality. My review focuses on two main points: improving the robustness of the parsing logic to prevent potential future conflicts between GPU and TPU naming, and increasing the precision of a unit test to better reflect the deterministic nature of the new hardware selection logic. Overall, this is a great improvement to the user experience.
keras_remote/core/accelerators.py
Outdated
|
|
||
| _TPU_ALIASES: dict[str, str] = { | ||
| "v5e": "v5litepod", | ||
| "ghostlite": "v5litepod", |
There was a problem hiding this comment.
I don't think *fish names are okay to use externally
There was a problem hiding this comment.
removed
There was a problem hiding this comment.
fyi: The fish names are exposed externally at https://cloud.google.com/skus/sku-groups/vertex-prediction.
JyotinderSingh
left a comment
There was a problem hiding this comment.
Thanks for the PR! Left a few comments.
keras_remote/core/accelerators.py
Outdated
|
|
||
| _TPU_ALIASES: dict[str, str] = { | ||
| "v5e": "v5litepod", | ||
| "ghostlite": "v5litepod", |
There was a problem hiding this comment.
fyi: The fish names are exposed externally at https://cloud.google.com/skus/sku-groups/vertex-prediction.
keras_remote/core/accelerators.py
Outdated
| _MULTI_GPU_RE = re.compile(r"^(.+?)(?:x|-)(\d+)$") # "a100x4", "l4-2" | ||
| _TPU_CHIPS_RE = re.compile(r"^([a-z0-9_]+)-(\d+)$") # "v3-8", "v5litepod-16" |
There was a problem hiding this comment.
_MULTI_GPU_RE = r"^(.+?)(?:x|-)(\d+)$" matches any name-number pattern, which is same shape as _TPU_CHIPS_RE = r"^([a-z0-9_]+)-(\d+)$".
eg., "l4-2" matches both regexes. The reason it works is that Multi-GPU is moved to the end of the function and TPU falls through (since "l4" is not in TPUS).
If anyone reorders the checks in the future, TPU parsing will intercept GPU (with dash) strings or vice versa.
Do you think we should let it be for now, or should we use this opportunity to implement what was discussed offline to utilize tpu:.. and gpu:... prefixes for accelerator name, which also helps popularise the TPU branding.
There was a problem hiding this comment.
Great idea. I've updated the core parsing logic to fully support and encourage explicit gpu: and tpu: prefixes. However, I also retained fallback parsing so that legacy unprefixed strings (like v5litepod or l4) continue to work as before!
|
remote/keras_remote/cli/infra/program.py Lines 233 to 236 in 70bd83e Just a note, we presently create all GPU node pools with Presently, We only need to map the Something like: @dataclass(frozen=True)
class GpuSpec:
gke_label: str
counts: dict[int, str] # count -> machine_typeThen the GPUS = {
"a100": GpuSpec("nvidia-tesla-a100", {
1: "a2-highgpu-1g",
2: "a2-highgpu-2g",
# ...
}),
"h100": GpuSpec("nvidia-h100-80gb", {
1: "a3-highgpu-1g",
# ...
}),
# ...
}Then we can update the guest_accelerators=[
gcp.container.NodePoolNodeConfigGuestAcceleratorArgs(
type=gpu.gke_label,
count=gpu.count,
),
], |
Good catch! I have refactored GpuSpecto mirror TpuSpec's behavior. It now uses a counts: dict[int, str] dictionary to map explicit integer counts directly to their corresponding optimal GKE machine type (e.g. mapping l4 count 8 perfectly to g2-standard-96). I updated keras_remote/cli/infra/program.py so guest_accelerators dynamically injects count=gpu.count instead of hardcoding 1. |
|
FYI: The local e2e tests are passing. |
This PR enhances the hardware parsing capabilities of keras-remote, allowing users to specify generic hardware requests (e.g., gpu-16, tpu-512) and automatically provisioning the most appropriate accelerator. It removes the strict requirement for users to know exact GKE hardware topologies, improving the overall developer experience while maintaining strict backward compatibility.